package main

import (
	"github.com/tal-tech/go-zero/core/conf"
	"github.com/tal-tech/go-zero/zrpc"
	"google.golang.org/grpc"
	"guli-shopping/product-service/config"
	"guli-shopping/product-service/protobuff/productProto"
	"guli-shopping/product-service/service"
)

var configPath string = "./config/application.yml"

func main() {
	//加载配置文件
	config := config.GetConfig()
	conf.MustLoad(configPath, config)
    PmsCategoryService := &service.PmsCategoryService{}
	PmsBrandService := &service.PmsBrandService{}
	PmsAttrGroupService := &service.PmsAttrGroupService{}
	PmsAttrService := &service.PmsAttrService{}
	PmsCategoryBrandRelationService := &service.PmsCategoryBrandRelationService{}
	PmsAttrAttrgroupRelationService := &service.PmsAttrAttrgroupRelationService{}

	server := zrpc.MustNewServer(config.RpcServerConf, func(server *grpc.Server) {

	    productProto.RegisterPmsCategoryCheckerServer(server,PmsCategoryService)
		productProto.RegisterPmsBrandCheckerServer(server,PmsBrandService)
		productProto.RegisterPmsAttrGroupCheckerServer(server,PmsAttrGroupService)
		productProto.RegisterPmsAttrCheckerServer(server,PmsAttrService)
		productProto.RegisterPmsCategoryBrandRelationCheckerServer(server,PmsCategoryBrandRelationService)
		productProto.RegisterPmsAttrAttrgroupRelationCheckerServer(server,PmsAttrAttrgroupRelationService)

	})
	defer server.Stop()
	server.Start()
}
